package com.zkingsoft.services.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zkingsoft.dao.WorkLogDao;
import com.zkingsoft.model.Project;
import com.zkingsoft.model.WorkLog;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.services.WorkLogService;

@Service("WorkLogService")
public class WorkLogServiceImpl implements WorkLogService{
	
	@Autowired
	private WorkLogDao workLogDao;
	
	@Override
	public List<WorkLog> selectWorkLogList(WorkLog workLog,PaginationVO pageVo) {
		// TODO Auto-generated method stub
		return workLogDao.selectWorkLogList(workLog,pageVo);
	}

	@Override
	public int selectWorkLogListTotal(WorkLog workLog) {
		// TODO Auto-generated method stub
		return workLogDao.selectWorkLogListTotal(workLog);
	}

	@Override
	public int addOrModify(WorkLog workLog) {
		// TODO Auto-generated method stub
		return workLogDao.addOrModify(workLog);
	}

	@Override
	public long addWorkLog(WorkLog workLog) {
		//判断这个项目今天是否已经创建日志
		 int flg=workLogDao.selectToDayWorkLog(workLog);
		 if(flg==0) {
		 workLogDao.addWorkLog(workLog);
		 workLogDao.updateUserTime(workLog.getSenderId(), workLog.getCreateTime());
		}
		 return flg;
	}

	@Override
	public List<Map<String,Object>> selectSummaryGraph(long projId) {
		return workLogDao.selectSummaryGraph(projId);
		
	}

	@Override
	public List<Map<String, Object>> selectUserLog(String userId) {
		
		return workLogDao.selectUserLog(userId);
	}

	@Override
	public List<WorkLog> selectReceiverId(long senderId) {
		// TODO Auto-generated method stub
		return workLogDao.selectReceiverId(senderId);
		
	}

	@Override
	public WorkLog selectWorkLogId(long workLog) {
		// TODO Auto-generated method stub
		return workLogDao.selectWorkLogId(workLog);
	}

	@Override
	public List<Map<String, Object>> selectUsersId() {
		return workLogDao.selectUsersId();
	}

	@Override
	public List<Project> selectProject(long userId) {
		return workLogDao.selectProject(userId);
	}

	@Override
	public int selectToDayWorkLog(WorkLog workLog) {
		return workLogDao.selectToDayWorkLog(workLog);
	}

	@Override
	public List<WorkLog> selectAllUserWork(WorkLog workLog, PaginationVO pageVo) {
		// TODO Auto-generated method stub
		return workLogDao.selectAllUserWork(workLog, pageVo);
	}

	@Override
	public int selectAllUserWorkTotal(WorkLog workLog) {
		// TODO Auto-generated method stub
		return workLogDao.selectAllUserWorkTotal(workLog);
	}
	
	
}
